﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ZPod.MTG.Windows
{
	public partial class CardList : Form
	{
		#region Private Properties

		List<Card> _cards;
		Card _selectedCard;

		#endregion

		#region Public Properties

		public Card SelectedCard
		{
			get
			{
				return _selectedCard;
			}

			set
			{
				_selectedCard = value;
			}
		}

		public int SelectedIndex
		{
			get
			{
				return cmbCards.SelectedIndex;
			}
		}

		#endregion

		#region Public Constructors

		public CardList(List<Card> cards)
		{
			InitializeComponent();
			_cards = cards;

			cmbCards.DataSource = cards;

			if (_cards.Count > 0)
			{
				cmbCards.SelectedIndex = 0;
			}

		}

		#endregion

		#region Private Methods

		private void buttonOk_Click(object sender, EventArgs e)
		{
			if (cmbCards.SelectedIndex >= 0)
			{
				_selectedCard = (Card)cmbCards.SelectedItem;
			}

			this.Close();
		}

		private void buttonView_Click(object sender, EventArgs e)
		{
			if (cmbCards.SelectedIndex >= 0)
			{
				var selectedCard = (Card)cmbCards.SelectedItem;

				using (CardDetailDialog dialog = new CardDetailDialog(selectedCard))
				{
					dialog.ShowDialog();
				}
			}
		}

		#endregion
	}
}
